<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button class="btn">点点我</button>


    <script>
        var btn = document.querySelector('.btn');
        const person = {
            name:'黎绍原',
            age:21,
            sex:'男'
        }
        const proxyPerson = new Proxy(person,{
            get(target,property){
                return target[property];
                console.log('捕获了');
            },
            set(target,property,value){
                target[property] = value;
                console.log('设置了');
            }
        })
        btn.onclick = function(){
            proxyPerson.id = 2
            console.log(proxyPerson);
            proxyPerson.age += 1
            console.log(proxyPerson.age);
        }
    </script>
</body>
</html>